<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <body class="tundra">
        <div id="systemMessage"></div>
        <div dojoType="dijit.Dialog" jsId="editschuserfDialog" title="用户信息修改">
            <form method="post" id="sendsaveuserform">
            <table>
             <tr><td></td>
                 <td><input dojoType="dijit.form.TextBox" jsId="editschuserid" type="text" name="id"></td></tr>
             <tr><td><label for="editschusername">用户名:</label></td>
                 <td><input dojoType="dijit.form.TextBox" jsId="editschusername" type="text" name="username"></td></tr>
             <tr><td><label for="editschusermail">邮箱地址:</label></td>
                 <td><input dojoType="dijit.form.TextBox" jsId="editschusermail" type="text" name="mailaddress"></td></tr>
             <tr><td><label for="editschusermail">所在分公司:</label></td>
                 <td><input dojoType="dijit.form.TextBox" jsId="editschusersubcompany" type="text" name="subcompany"></td></tr>
             <tr><td><label for="editschusermemo">备注:</label></td>
                 <td><input dojoType="dijit.form.TextBox" jsId="editschusermemo" type="text" name="memo"></td></tr>      
             <tr><td></td>
                 <td><input dojoType="dijit.form.TextBox" jsId="editschuserpassword" type="text" name="password"></td></tr>       
             <tr><td align="center" colspan="2">
                 <button dojoType="dijit.form.Button">保存
                   <script type="dojo/method" event="onClick">
                    var items = searchusergrid.selection.getSelected();
                    //saveUserForTable(items[0]);
                    saveUserForTable();
                    searchuserstore.setValue(items[0], "username",editschusername.getValue());
                    searchuserstore.setValue(items[0], "mailaddress",editschusermail.getValue());
                    searchuserstore.setValue(items[0], "subcompany",editschusersubcompany.getValue());
                    searchuserstore.setValue(items[0], "memo",editschusermemo.getValue());
                    editschuserfDialog.hide();
                   </script>
                 </button>
                 <button dojoType="dijit.form.Button" type="button" onClick="editschuserfDialog.hide();">取消</button></td></tr>
            </table>
            </form>
        </div>
        
        <div dojoType="dijit.Dialog" jsId="changepwdfDialog" title="重设用户密码">
            <form method="post" id="sendchangepassword">
            <table>
             <tr><td><label for="newpassword">新密码:</label></td>
                 <td><input dojoType="dijit.form.TextBox" jsId="newpassword" type="password" name="newpassword"></td></tr>
             <tr><td><label for="newpassword2">新密码确认:</label></td>
                 <td><input dojoType="dijit.form.TextBox" jsId="newpassword2" type="password" name="newpassword2"></td></tr>
            </table>
            </form>
        </div>
        
        <div dojoType="dijit.Dialog" jsId="delschuserfCmDialog" title="系统消息">
            <table>
              <tr><td><label id="delusermessage" for="editschusername">确定删除？</label></td>
                 <td></td></tr>
              <tr><td></td></tr>
              <tr><td align="center" colspan="2">
                 <button dojoType="dijit.form.Button" type="submit">确认
                   <script type="dojo/method" event="onClick">
                    var items = searchusergrid.selection.getSelected();
                    if (items.length) {
                        dojo.forEach(items, function(selectedItem) {
                            if (selectedItem !== null) {
                                searchuserstore.deleteItem(selectedItem);
                                deleteUserForTable(selectedItem);
                            }
                        });
                    }
                   </script>
                 </button>
                 <button dojoType="dijit.form.Button" type="button" onClick="delschuserfCmDialog.hide();">取消</button></td></tr>
            </table>
        </div>
        <div jsId="editschuserfSyinfoialog" title="系统消息" dojoType="dijit.Dialog">
        <table>
        <tr><td>请您先选中用户</td></tr>
        <tr><td align="center">
             <button dojoType="dijit.form.Button" type="button" onClick="editschuserfCmDialog.hide();">确定
               <script type="dojo/method" event="onClick">
                    editschuserfSyinfoialog.hide();
               </script>
             </button> 
        </td></tr>
        </table>
                         
        </div>
        <br>
        <div id="searchuser">
             <label for="username">按用户名检索:</label>
             <input name="username" dojoType="dijit.form.TextBox" jsId="searchuser_username" value="" intermediateChanges="true" trim="true" required="true">
             <button dojoType="dijit.form.Button" type="submit" name="submitButton" value="Submit">开始搜索
                <script type="dojo/method" event="onClick">
                  searchUserForTable();
                </script>
             </button>
        </div>
        <br><br>
    <div id="operation">
    <button dojoType="dijit.form.Button" jsId="delschuserButton">删除
      <script type="dojo/method" event="onClick" args="evt">
               var items = searchusergrid.selection.getSelected();
               if (items.length) {
                  delschuserfCmDialog.show();
                  delschuserfCmDialog.setAttribute("title", "删除用户"+items[0].username);
               } else {
                  editschuserfSyinfoialog.show();
               }
      </script>
    </button>
    <button dojoType="dijit.form.Button" jsId="editschuserButton">编辑
      <script type="dojo/method" event="onClick" args="evt">
               var items = searchusergrid.selection.getSelected();
               if (items.length) {
                   dojo.forEach(items, function(item) {
                   if (item !== null) {
                       editschuserfDialog.show();
                       editschuserid.setValue(item.id);
                       editschusermail.setValue(item.mailaddress);
                       editschusersubcompany.setValue(item.subcompany);
                       editschusername.setValue(item.username);
                       editschuserpassword.setValue(item.password);
                       editschusermemo.setValue(item.memo);
                       editschuserid.setAttribute("style","visibility:hidden");
                       editschuserpassword.setAttribute("style","visibility:hidden");
                       //editschusername.setAttribute("disabled",true);
                   }});
               } else {
                  editschuserfSyinfoialog.show();
               }
        </script>
      </button>
      <button dojoType="dijit.form.Button" jsId="previousUserButton">上一页
                <script type="dojo/method" event="onClick">     
                  previous();
                </script>
      </button>
      <button dojoType="dijit.form.Button" jsId="nextUserButton">下一页
                <script type="dojo/method" event="onClick">
                  next();
                </script>
      </button>
      </div>
   <span dojoType="dojo.data.ItemFileWriteStore" rowSelector="20px" jsId="searchuserstore" url="searchuser.action?currentPage=0"> </span>
   <div jsId="searchusergrid" dojoType="dojox.grid.EnhancedGrid" style="width: 98%; height: 70%;" structure="searchuserlayout" selectionMode="single" store="searchuserstore" plugins="{nestedSorting: true, dnd: true, indirectSelection:true}">
   </div>
 
    </body>
</html>